package cn.blt.single;

import cn.blt.security.auth.entity.SysUser;

/**
 * 单例用户类
 * @author yuhag
 * @date 2022/08/26
 */
public class UserSingle {

    private Long id;
    private String realName;
    private String nickName;
    private String userAcct;

    public Long getId() { return id; }
    public String getRealName() { return realName; }
    public String getNickName() { return nickName; }
    public String getUserAcct() { return userAcct; }

    public static UserSingle instance = new UserSingle();

    public synchronized static UserSingle getInstance() {
        return instance;
    }

    public synchronized static void setInstance(SysUser user){
        if (instance.id == null){
            instance.id = user.getId();
        }
        if (instance.realName == null){
            instance.realName = user.getRealName();
        }
        if (instance.nickName == null){
            instance.nickName = user.getNickName();
        }
        if (instance.userAcct == null){
            instance.userAcct = user.getUserAcct();
        }
    }

}
